package com.example.zyfypt_611cgt.fragments;

import android.content.Context;
import android.content.SharedPreferences;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

public abstract class  BaseFragment extends Fragment {

    protected Context context;
    private SharedPreferences sp;

    private final String FILE = "login";
    private final String KEY_SESSION = "session";
    private final String KEY_NAME = "name";


    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        this.context = context;
        sp = context.getSharedPreferences(FILE, Context.MODE_PRIVATE);
    }

    protected String getSessionID(){
        return sp.getString(KEY_SESSION, "");
    }
    protected String getUsername(){
        return sp.getString(KEY_NAME, "");
    }
}
